import React, { useState } from 'react'
import styles from '../router-v5-nest/Login.module.css'
import { useNavigate } from 'react-router-dom'
export default function Login () {
  const [username, setUsername] = useState('')
  const [password, setPassword] = useState('')

  const navigate = useNavigate()
  const login = () => {
    // console.log(password, username)
    if (username === 'admin' && password === '123') {
      navigate('/layout')
    } else {
      alert('用户名或密码错误')
    }
  }

  return (
    <div className={styles['login-container']}>
      <p>
        用户名:
        <input value={username} onChange={e => setUsername(e.target.value)} />
      </p>
      <p>
        密码:
        <input value={password} onChange={e => setPassword(e.target.value)} />
      </p>
      <p>
        <button onClick={login}>登录</button>
      </p>
    </div>
  )
}
